package com.jiazhong.boot.redis.shuxin.test;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jiazhong.boot.commons.bean.plus.Emp;
import com.jiazhong.boot.commons.util.JsonResult;
import com.jiazhong.boot.redis.shuxin.service.EmpService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
@Slf4j
public class App {
    @Resource
    private EmpService service;

    @Test
    public void a1() {
        JsonResult result = service.findById1(8005);
        log.info("result:{}", result);
    }

    @Test
    public void b1() {
        JsonResult result = service.deleteById1(7980);
        log.info("result:{}", result);
    }

    @Test
    public void c1() {
        Emp emp = new Emp();
        emp.setEmpNo(8005);
        emp.setEname("赵文哲");
        emp.setJob("程序员");
        emp.setSal(7898.0);
        emp.setHireDate("2020-08-08");
        emp.setComm(89.0);
        JsonResult result = service.updateEmp1(emp);
        log.info("result:{}", result);
    }

    @Test
    public void a2() {
        JsonResult result = service.findById2(8005);
        log.info("result:{}", result);
    }

    @Test
    public void b2() {
        service.deleteById2(8006);
    }

    @Test
    public void c2() {
        Emp emp = new Emp();
        emp.setEmpNo(7953);
        emp.setEname("马乐乐");
        emp.setJob("网页设计");
        emp.setSal(88818.0);
        // emp.setHireDate("2020-08-08");
        emp.setComm(44.5);
        emp.setDeptNo(30);
        JsonResult result = service.updateEmp2(emp);
        log.info("result:{}", result);
    }

    @Test
    public void d1() {
        JsonResult result = service.findPage1(4);
        log.info("result:{}", result);
    }

    @Test
    public void d2() {
        JsonResult<IPage<Emp>> result = service.findPage2(3);
        log.info("result:{}", result);
        IPage<Emp> iPage = result.getData();
        iPage.getRecords().forEach(e -> {
            log.info("e:{}", e);
        });
    }

    @Test
    public void d3() {
        JsonResult<IPage<Emp>> result = service.findPage3(1);
        log.info("result:{}", result);
        IPage<Emp> iPage = result.getData();
        iPage.getRecords().forEach(e -> {
            log.info("e:{}", e);
        });
    }

    @Test
    public void b3() {
        JsonResult result = service.deleteById3(7944);
        log.info("result:{}", result);
    }


    @Test
    public void c3() {
        Emp emp = new Emp();
        emp.setEmpNo(7909);
        emp.setEname("张三三");
        emp.setJob("网页设计");
        emp.setSal(88818.0);
        // emp.setHireDate("2020-08-08");
        emp.setComm(44.5);
        emp.setDeptNo(30);
        JsonResult result = service.updateEmp3(emp);
        log.info("result:{}", result);
    }
}
